#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=1e5+10;
int n;
struct node
{
	int t,d;
	db p;
	bool operator <(const node b)const
	{
		return p<b.p;
	}
}a[MAXN];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i].t=read();a[i].d=read();
		a[i].p=(db)a[i].t/a[i].d;
	}
	sort(a+1,a+1+n);
	LL ans=0,cnt=0;
	for(int i=1;i<=n;++i)
	{
		ans+=cnt*a[i].d;
		cnt+=a[i].t*2;
	}
	printf("%lld\n",ans);
	return 0;
}
